from __future__ import print_function
import torch

# 没有初始化的5*3矩阵：
x = torch.empty(5, 3)
print(x)

# 创建一个随机初始化矩阵：
x = torch.rand(5, 3)
print(x)

# 构造一个填满0且数据类型为long的矩阵:
x = torch.zeros(5, 3, dtype=torch.long)
print(x)

# 直接从数据构造张量
x = torch.tensor([5.5, 3])
print(x)

x = x.new_ones(5, 3, dtype=torch.float64)
print(x)

x = torch.randn_like(x, dtype=torch.float)  # 指定新的数据类型
print(x)

print(x.size())
print(x.shape)
